implements the function of terminalController