implement NPV function