use struct as an index to buffer