implemented forward algo