use lambda expressions to compact the code