add insert into db and plot function