Rework the error detection -- it's still not working