Added further optimizations for plotting graph