merged both query listeners into one