Tweaked Badge algorithm