refact the Query processing
merged from the remote branch