Move the download image to a separate method and use th picid for image filename.
There are too many variations of where the filename may be in the url to bother about.