the hanoi function