simplify and fix bug in FailSafe implementation