Refactor for require.js