update the loop function in course file