refactored wav code into separate file