improved the traverse implementation, now powered by fold