Put graph script into closure