Refactor application.js