refactor window related code into windowManager