fixed a bug with check_range and union the sets