implement the infect algorithm