Refactor using lambda to reduce duplication