2002 Sportsman Wiring Q

My 2002 Sportsman 500 wasn’t charging so I bought an aftermarket stator and voltage regulator. The kid who works for me installed it but can’t figure out where a wire goes.

He had the brown ground wire plugged into that comes off the bottom rear of the ignition coil jumped over to the front terminal on the ignition coil and couldn’t figure out what the blue wire went to. According to the wiring diagram the blue wire was supposed to go to that terminal if I read it correctly and the brown goes to a ground I think. So I swapped the blue and brown but can’t figure out where that brown wire is supposed to go.

I started the machine like shown in the photo, had to pull it because battery was dead (I left key on) and it started/ran fine but wouldn’t shut off. Kill switch near brake and key wouldn’t shut it down.