added for loop, corrected igraph calls, etc.