implemented loopy beleif propagation