Implemented proper resizing