fixed program getting stuck after error