implemented the resize function