refactor fileupload