https://eddelbuettel.com/dirk/code/smtm.html
