do more refactor for upload