refactored javascript to use require.js