using lambda to simplify code