cleanup of query example code and plot script