- refactored some parts of the code to optimize the failure behavior