added a plotting function