You can default `failed` to false, and then remove both of these else blocks.  You can then just set `failed` to true once you know you're okay.