improved badge alert logic