Fix GCD function