Use lambdas to remove duplicated boilerplate