Fix database filtering