Fix course index in for loop