rebuild matrix