added error handling for processQueries