worked on calculatePeak function, need to test