add timeout to download image & refactoring.