improvements to NPV function