refactor for phonegap build