refactored resizing