Fix to the resize function