plotting function now works