Updated to simplify the for loop