now uses 2d array