added failure logic