use correct indexing variable in tavg kernel loop