add code to get optimal r