add factory, to allow for use with AMD and globals