Resize only when necessary