fix Kprogram calculation