restructured index, implemented end_turn