refactor window search