Refactoring to RequireJS