Updated to check the window width