made wave calc into individual functions