added regcd and egcd