Updated the r code