main js app and refactoring /templates