write receive function in messagepasser