fix nil panic in generator.go