Merged the resize function