Now the previous code doesn't want to erase
What does this mean? Are you referring to the previous hex file on the Arduino?