working on factor graph