fixing GetNeighbour function with dirty hack and linear runtime
merged