fixed some filtering bugs and special cases