grund for connection based 2d algoritm