refactored score method