add exception handling to receiveMsgAndHandle