Refactored logic in limited_infection, added comments