initialize i to 0 in server