fix window calculation