rewrite using let and iter