implemented backward sampling