changed variable scoping; not sure why previous queries are persisting