Functor based implementation