Factor message logic out of popup