Most of the inference part working