fixed critical bug with segments cleaning