Refactor resize method