updated to work with cordova 3+