code refactor for graph generation and image name with time