bug fix that took hours to fix argh