Implementing the n-step return calculation