updated with AMD/commonJS compatible code