modified to work with or without requirejs