factor out the kl function.