Refactored with require.js