import re


def normalize_whitespace(text):
    """
    This function normalizes whitespaces, removing duplicates.
    """
    corrected = str(text)
    corrected = re.sub('\s', ' ', corrected)
    corrected = re.sub(r"( )\1+",r"\1", corrected)

    return corrected.strip(" ")