refactored application.js a bit