working on compatibility with phonegap