refactored hanoi to use prototype