better terminal support in sample program