Refactored for require.js