Fixing mailbox query bug