DRYing up resizing code, refactor into it's own function