Added code to save data
Fixed amplitude with distance.