added requirejs and modularized js code