refactor lambda expression

Refactor the two lambda expressions to be cleaner.