GCD implemetation java