Reverted changes in is_terminal function