fixed 0-gcd issue