properly delete duplicate layers instead of hiding and undoing