changed smith form algoritm

Now works with larger matrices too.