Refactored and started using requirejs