refactored scorecard function