replaced double with BigInteger