updated with comments, more tests, and verbal answers.