Updated resize logic