correct refactor R