Fix bug with KD checking