Refactor tui