refactor window search functions