implemented plot function