modified r code