some useful code in my query works lab