kd functions