Refactored evaluate method