Removing uneeded list elements