Move alert handling logic to a service