implemented fold