Refactor score method in score.rb