move final plot to its own function