Updated to loop and re-predict if a prediction fails