changes from code review, thanks! also added a unit test.