modified plot function