continue to refactor for phonegap