refactor window system