Updated code to work with RequireJS