added failure trap