Bug fixed for query calls