fix a window scoping bug