fixed bug in runquery