Bug fix on gcd