Refactored: moved the factory method into the lambda class