Version that passes R CMD CHECK