Fixed avoidance algorithm (again)