added processQuery function to handle what functions should be called