fix reference bug
handle query and operations correctly