Refactored generate card_score task, and optimized it a bit