re-factored for require.js

js is now separated into modules