updated based on feedback from @jrrideout