added step 4 in BP algorithm, still incomplete