small mods to R file