Incorporate Lenka Vyslouzilova modification

See
https://class.coursera.org/rprog-002/forum/thread?thread_id=370#comment-
953 for the origin of the modification