removing bad elements