added some figure-making code