Added a working plot function