first version of inference algo