Matrix search algorithm implemented