Improve the performance of terminal ditection