cleaned r code