added code to general R