Corona Crashes when I use this Code

I don’t know if this is a problem with my code or a problem with CoronaSDK, but whenever I use this code, when it tries to call the function (from Options button) it works but instantly crashes half a second later:

local ui = require("ui")  
function createmainmenu()  
 Options = ui.newButton{  
 default = "buttonBlue.png",  
 over = "buttonBlueOver.png",  
 onPress = clearmainmenu,  
 onRelease = clearmainmenu,  
 text = "Options",  
 emboss = true  
 }  
end  
function clearmainmenu()  
 if Options ~= nil then  
 Options:removeSelf()  
 end  
end  
--Start  
createmainmenu()  

Could someone shed some light on this error please? I only ask questions if I’ve exhausted all my options and its pretty hard to debug something that doesn’t give me a debug message… [import]uid: 44393 topic_id: 8155 reply_id: 308155[/import]

Your calling a function onPress to nil the button(Options) and then calling it again onRelease to nil the button but its already been removed causing the crash… i’d assume… [import]uid: 33866 topic_id: 8155 reply_id: 29065[/import]

I removed the OnRelease part and forward declared the button and the functions, still a crash.

EDIT: If I change onpress to onrelease it works, kind of an annoying error (glitch?) but I guess its a good work around, thanks everyong. [import]uid: 44393 topic_id: 8155 reply_id: 29092[/import]