fix alert handling bugs