added extended euclidean algorithm