Updated resize function.