Mega r3 retaining info

Ok I am new to arduino. I have two megas on happens to be an R3. I have been running a cnc with them for about two months and suddenly an issue has arisen. The cnc started acting up. When I would tell it to go 5 inches to right it would go then go back to the left 5 inches when I would ask it to go right again. There was no rhyme or reason on how many times it would just switch directions. So I decided to just reprogram the arduinos and start from scratch. I am using lightburn as my software. Now when I try to reprogram the R3 It is retaining the output steps from previous program. I have tried on different computers, 3 different cords and even uploading bootloader and then back to grbl. Still the outputs are not being rewritten and the board is still acting erratic. Any help would be greatly appreciated.

The board is broken, get a new one load up the old working code.

Sounds like your CNC software!

how would you know its broken for sure? Is there a way to tell?

ok I believe it is a com error between software and arduino, but why can I not get the steps to clear out of the arduino. As I mention the regular Arduino mega not the r3 was able to be reprogrammed and the steps went back to 250 but the r3 stays at 143.616 that I input when calibrating my cnc.

Sounds like a bad connection on the DIRECTION pin of the stepper driver. Is the X-axis stepper the only one acting up? Does it change if you swap the X and Y stepper drivers?