code refactor for image uploader