updates to kd_comp for efficieny