adding threshold and dealing with failure