Further refactor graph creation