fix window handling