compute size only once