Backward algorithm