added final exhaustive inference code