moved factory instantiation into method