refactoring wiggle.py