Several changes to make the collateGraph function work