add alerts and fix max_id check