Take a look at how you're accessing your 2d array. Plug in some values for x and y and see what value you're actually looking at.

map[x][y]

What value are you accessing if x is 3 and y is 2?...