ce: implement queries in a faster way