refactor upload file thing