Made factory function a free function