refactored js code layout to separate app/controller/directives