changed formatting, added stripped-down gcd function