Implemented better for-loop