refactor with require.js