Adding failure handling