Your logic is not that good. You dont need to keep a app object var local to the procedure and set it and then destroy it every button click. If you need your app object available across several procedures then it would be better to have them module level vars so you dont need to keep doing a set/destory/set in every procedure.