added requirejs and refactored existing js to use it