updated to be compatible with amd / requirejs