moves message handling to io