Use of lamdbas to simplify code