cleaned up some code for phonegap