made it stop if R is not positive definite