A routine to remove dud galaxies