adding sort to unique depths
minor changes