Added some logic to account for use with cordova