modified code for evaluating lshep approximation at each iteration