modified for cran check