Use requirejs to refactor the code