Update badges_controller.rb

refactor a bit and more functional