refactoring of search for window(s)