Fixing the bug where the signed integer is overflowing by using BigInteger