made gcd call more thread safe