Working code with stuttery object avoidance