KBS algorithm