Added code to handle the reset if the code has been rerun