Turned this into an AMD using requirejs