refactor. modularized using requireJS