Fix window size calculation