Fixed a bug in married query