added nested if/else to include failure class