refactor and add specs to alert