Wrap resize in a function.