renamed reduce to fold. added fold-right, and proper reduce