q defer implemented for factory