Guests comment form – prevent duplicate email addresses

function preprocess_mycomment($commentdata) {
    $existing_comments = get_comments( array('post_id' => 31691) ); // I run the code for one specific page only
    foreach ($existing_comments as $comment) {
         $previous_comments = $comment->comment_author_email; // email address send by the current poster
        
         if ( $previous_comments == $commentdata['comment_author_email'] ) { // comparing the current email address with the previous ones in database.
            wp_die('The email ' . $previous_comments . ' has already been used.');
            }
    }

    return $commentdata;

}
add_filter('preprocess_comment', 'preprocess_mycomment');