Refactored using factories