modified start and end of program
fix zero reset for errors