removes unused elements