Updated Factory function