Implement gcd method