Handle more complex filtering. Probably still not quite right.