Refactored to use RequireJS