Refactored to use requirejs