added crash detection method and improved comments