changed Signature of 'query' function so most parameters are marked as optional