refacotring amd/commonjs support