fix bug in window counting