looping function for infect_recover