Restructured code to use RequireJS