modify index each button function