removing redundant elements