resize_window function now handles height changes