new script to deal with cgquery output