Fix resize logic