adapted to cordova 3