adding inference algorithm