improved resizing behavior