correct logic with coordinates, support 8 bit wav, better error handling