Expansion and refinement of the previous bug fix