work on 2d array matrix format