Replace for loop with enumeration