updated to be requireJS compatible