eliminate imperative loops