updated the resize function