Moving badge function to an badge model.