completed spiral function