replace ranges in for loops with enumerate