added more parameters to afterQuery callback