finally made it work. I made some really stupid mistake: in findNeighbor, m and n where wrong when judge boundaries. Initialating a 2D vector with given size is not very straightforward