fix database filtering