refactor for requireJS