appjs refactoring