cleaned up and documented with RMarkdown