refactor files upload