better handling of window resizing