Fix gcd function