Updated r script