badge logic