probably row_gcd has the error.  extended euclid works.