reformatted code according to Google R style guide