Fixed filtering function to work both in colored/non colored outputs