svd code much cleaner