refactor resize method