download image method refactor