refactor to use require.js