window extraction code