refactor graph function/methods in same manner