move window to ui and refactor it