refactor alerts controller