refactored out the image resizing method