refactor the code a little, ready to split Badges.xml