Lateral recurrence dynamically refines visual representations for task performance