refactored avatar uploader