Fixed problems with queries