added requireJS and refactor codes