Refactored to a phonegap plugin with config