UPDATED using grunt.
UPDATED minifying main.js
UPDATED refactored code is working now.