finished 2D matrix search method 2