refactored main Window.