fix #6599

Jeff, can you review this. I don't know how to test it effectively.