changed how compare graph data is queried for efficiency, made SQL queries more robust