implementing LSMC algorithm