refactor to use new sparse 2d array class