fix subtle and hard-to-find bug
thoughts and test cases
comment