Appjs refactor