edited code to allow for GCD functionality