Modified the graph rendering function