slight refactoring and optimization
add another test
further refactoring, thinking we understand more now