Forward algorithm do