Fix window resize bug