udpate diagnostic R code