converted from using canvas to 2d array