Fixed bug in terminal mode