refactored uploader.js