ported to require.js