Non-recursive approach with closetozero. Maybe works.