Fixed the resize function