singular matrix error needs to be fixed