Scene switches back after scene transition

In my game, I am switching from one scene to another. As soon as it transitions into the next scene, the scene that it is supposed to transition to does another transition to the screen that it was just on and then the screen goes black. Does anyone else have this problem or knows why it happens?

here is my code:

[lua]

local storyboard = require(“storyboard”)

local scene = storyboard.newScene()

local widget = require “widget”

local menuBtn

– ‘onRelease’ event listener for playBtn

local function onMenuBtnRelease()

    – go to level1.lua scene

    storyboard.gotoScene(“creds”, “fade”, 6000)

    

    

    return true    – indicates successful touch

end

– Called when the scene’s view does not exist:

function scene:createScene( event )

    local screenGroup = self.view

– create a widget button (which will loads level1.lua on release)

local menuBtn = widget.newButton{

        --label=“Play Now”,

        --labelColor = { default={255}, over={128} },

        default=“playbutton1.png”,

        over=“playbutton2.png”,

        width=230, height=65,

        onRelease = onMenuBtnRelease    – event listener function

    }

    menuBtn:setReferencePoint( display.CenterReferencePoint )

    menuBtn.x = 850

    menuBtn.y = 400

    menuBtn.xScale = 2.5

    menuBtn.yScale = 2.5

    

    screenGroup:insert(menuBtn)

    

end

function scene:enterScene( event )

    local screenGroup = self.view

    

    --physics.start()

print( “ending: enterScene event” )

    

    – remove previous scene’s view

    storyboard.purgeScene( “level1” )

    

end

– Called when scene is about to move offscreen:

function scene:exitScene( event )

    local screenGroup = self.view

    --physics.start()

    --storyboard.removeScene( “menu” )

    --storyboard.removeAll()

    --physics.stop()

    

    – INSERT code here (e.g. stop timers, remove listenets, unload sounds, etc.)

    

end

– If scene’s view is removed, scene:destroyScene() will be called just prior to:

function scene:destroyScene( event )

    local screenGroup = self.view

    --storyboard.removeAll()

    --storyboard.removeScene(“menu”)

    --physics.start()

    

    if menuBtn then

        menuBtn:removeSelf()    – widgets must be manually removed

                menuBtn = nil

    end

end


– END OF YOUR IMPLEMENTATION


– “createScene” event is dispatched if scene’s view does not exist

scene:addEventListener( “createScene”, scene )

– “enterScene” event is dispatched whenever scene transition has finished

scene:addEventListener( “enterScene”, scene )

– “exitScene” event is dispatched whenever before next scene’s transition begins

scene:addEventListener( “exitScene”, scene )

– “destroyScene” event is dispatched before view is unloaded, which can be

– automatically unloaded in low memory situations, or explicitly via a call to

– storyboard.purgeScene() or storyboard.removeScene().

scene:addEventListener( “destroyScene”, scene )


return scene

[/lua]

Thanks in advance