added forward algorithm code