gcd updated, some code is unnecessary