refactor image uploader