need to solve the looping problem