Added a window resize detection