optimize generator callback structure.