moved factory to top level