refactoring to requirejs