modify the inv() to pinv().