Analysis of Modular Inverse and Improvement of Extended Euclid Algorithm