fixed ctrl-c bug for code that runs too long