replaces export of module to be a factory instead of a constructor function