Move resize logic into a private method