index write function