Code Optimization

Iterator changed to for loop