my implementation was quite complex - bill the lizard's version shows the erring of my ways.