minor code tidying, no major thinking
added roxygen