refactored the code & added an image save + image thumb feature