Was quitting the loop too early