Refactor object generation