Adjusted logic to match validated results.