message passing code finished