Cleaned up a loop for readability