refactored some more and added for the ability to process multiple graphs in one run