added extended euclidean