correct and test plot functionality