fixed a few things with queries