added commands to write-out figures