refactor cpp code
add labels and legend to plots
add some theory