Refactored the factories