code to remove unwanted entries