Moved plot function in to its own source