performance optimization, replacing big.Int