updated based on second round of comments from @jrrideout