this was the trickiest bug to fix