a more refined version of spiral.py