modify by using graph class