improve hash_fold to support pipes