gcd + refactor1