update code and test plot