tidied up queries a little bit