main.lua: attempt to index upvalue 'bricks' (a function value)
<p>Got this error while transitioning from "main menu" to the game screen. On click of "Play" , main-menu disappears and level 1 appears. For this level, I have added bricks using displayGroup.
Getting error at line <strong>bricks:toFront();</strong> If I remove this line/ place somewhere else, then getting error at <strong>bricks.insert(bricks, brick)</strong></p>

<pre><code>playButton:addEventListener("tap", loadGame);

function loadGame(event)
    if event.target.name  == "playbutton" then
        transition.to(menuScreenGrp, {time = 0, alpha = 0, onComplete = addGameScreen});
        playBtn:removeEventListener("tap", loadGame);
    end
end

function addGameScreen()
   -- code for displaying background and other stuff
   loadLevel1();
end

function loadLevel1()

    currentLevel = 1;
    bricks:toFront();  -- Got error here

    for row = 0, numOfRows - 1 do
    for column = 0, numOfColumns - 1 do

      --logic to position bricks
      physics.addBody(brick, "static", {density = 1, friction = 0, bounce = 0})
      bricks.insert(bricks, brick)

    end
  end
end
</code></pre>