Refactoring generate and upload logic with J