bug fixed in calculating distances from peak end
rearrange source file