add plot func and some edits