Graph conversion working, need to refactor code