Cleanup replaced some function with a for-each