refactoring resize function