fix cailb algorithm