Refactoring on uploadFile