fixed R plot function