optimized condition query for tiemout