added plotting function