need app js refactor