Fix resize function