improvements in detection of terminal