Update to include acknowledgment of David's code snippet