Move badge into its own function