Extracted function for easy wave implementation