Query bug fixed