Refactor for sending/receiving msgs