Full code for spiral