Added KB and Inference Code