Refactor main method in Producer