Simplify implementation with HOFs.