Refactor to use RequireJS