updated to write alert history