Fixed the causal algorithm