fix case when boundaries are not unique