r code 20130715 v3