added termination criterion and commented out the different inferences