output with code refactored using factories