refactor calculateScore