refine upload handling