added function plot 
minor bugs fixed