working version with wave