move gcd out