refactor file upload