fixed a leak where plot wasn't closing and writes over the first image with the second