diff --git a/MeshLib/Elements/Element.cpp b/MeshLib/Elements/Element.cpp
index 43060dc86918b1d89c10ceb829c13f89a0b6ec22..9c4ed299cce2128767881878de9fb0944bc60c44 100644
--- a/MeshLib/Elements/Element.cpp
+++ b/MeshLib/Elements/Element.cpp
@@ -41,18 +41,18 @@ void Element::setNeighbor(Element* neighbor, unsigned const face_id)
 	this->_neighbors[face_id] = neighbor;
 }
 
-unsigned Element::addNeighbor(Element* e)
+boost::optional<unsigned> Element::addNeighbor(Element* e)
 {
 	if (e == this ||
 		e == nullptr ||
 		e->getDimension() != this->getDimension())
-		return -1;
+		return boost::optional<unsigned>();
 
 	unsigned nNeighbors (this->getNNeighbors());
 	for (unsigned n=0; n<nNeighbors; n++)
 	{
 		if (this->_neighbors[n] == e)
-			return -1;
+			return boost::optional<unsigned>();
 		if (this->_neighbors[n] == nullptr)
 			break;
 	}
@@ -72,11 +72,11 @@ unsigned Element::addNeighbor(Element* e)
 				if ((++count)>=dim)
 				{
 					_neighbors[ this->identifyFace(face_nodes) ] = e;
-					return e->identifyFace(face_nodes);
+					return boost::optional<unsigned>(e->identifyFace(face_nodes));
 				}
 			}
 
-	return -1;
+	return boost::optional<unsigned>();
 }
 
 MeshLib::Node Element::getCenterOfGravity() const
diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h
index 168d80b0b727fa8f07c295643e45f48fe04e4913..b1b7ceb83be1285ca923c6b577d20796704934f5 100644
--- a/MeshLib/Elements/Element.h
+++ b/MeshLib/Elements/Element.h
@@ -17,6 +17,8 @@
 
 #include <vector>
 #include <limits>
+#include <boost/optional.hpp>
+
 #include "MeshEnums.h"
 #include "Mesh.h"
 #include "MeshQuality/ElementErrorCode.h"
@@ -45,7 +47,7 @@ public:
 	 * neighbour-list and the face id of the neighbour connected to this element
 	 * is returned. Otherwise the maximum value of the value type is returned.
 	 */
-	unsigned addNeighbor(Element* e);
+	boost::optional<unsigned> addNeighbor(Element* e);
 
 	// Calculates the center of gravity for the mesh element
 	MeshLib::Node getCenterOfGravity() const;
diff --git a/MeshLib/Mesh.cpp b/MeshLib/Mesh.cpp
index 855b47f79e9ba21cf555b816fb1fd0b59f333388..180d135432f7a926c22710a7cf42b147ac8c87f2 100644
--- a/MeshLib/Mesh.cpp
+++ b/MeshLib/Mesh.cpp
@@ -12,6 +12,8 @@
  *
  */
 
+#include "boost/optional.hpp"
+
 #include "Mesh.h"
 
 #include "Node.h"
@@ -178,10 +180,10 @@ void Mesh::setElementNeighbors()
 
 		for (auto neighbor = neighbors.begin(); neighbor != neighbors_new_end; ++neighbor)
 		{
-			unsigned const opposite_face_id = element->addNeighbor(*neighbor);
-			if (opposite_face_id != unsigned(-1))
+			boost::optional<unsigned> const opposite_face_id = element->addNeighbor(*neighbor);
+			if (opposite_face_id)
 			{
-				(*neighbor)->setNeighbor(element, opposite_face_id);
+				(*neighbor)->setNeighbor(element, *opposite_face_id);
 			}
 		}
 		neighbors.clear();