Update badge only when necessary