Separate out ploting and writing functions out of class