Fixed bug in foldr