some work on complex condition query