Change pinv2 to more effective pinv