working version of grep hack to speed up graph parsing