fixed db query to return ordered, correctly filtered results