fixing resizing logic