fixed ordering error in ext_gcd