! refactoring and changes for phonegap