fixed error in loop function