finished refactoring for simulatn work of gui and tui