Add custom implementation of foldr