lead type query bug fix