def METHOD_NAME(spectrum, m):
    """Rectangular smoothing function.
    Parameters
    ----------
    spectrum: str
        a spectrum object
    m : int
        the smoothing width, must be an odd integer more than 3
    Returns
    -------
    smooth_spect: a spectrum object
    """
    if m < 3:
        raise ValueError("Error:Smoothing width less than 3")
    if m % 2 == 0:
        raise ValueError("Error:Smoothing width not odd")
    smooth_spec = copy.deepcopy(spectrum)
    smooth_spec.counts = []  # reset counts
    ext = int((m - 1.0) / 2.0)
    i = 0
    # 3 stages of loops a small one at start and end to deal
    # with end cases and a main one for bulk of spectrum
    while i < ext:
        smooth_spec.counts.append(spectrum.counts[i])
        i = i + 1
    i = ext
    while i < (len(spectrum.counts) - ext):
        j = i - ext
        sum_m = 0
        while j <= (i + ext):
            sum_m = sum_m + spectrum.counts[j]
            j = j + 1
        smooth_spec.counts.append(sum_m / m)
        i = i + 1
    while i < (len(spectrum.counts)):
        smooth_spec.counts.append(spectrum.counts[i])
        i = i + 1
    smooth_spec.spec_name = spectrum.spec_name + " smoothed"
    return smooth_spec