fix bug with GCD