fixed up the code so it works with require.js