refactor appjs