diff --git a/libwccl/values/matchvector.cpp b/libwccl/values/matchvector.cpp
index 24b77b8e01f8dea3b8d16298789585e4a785635d..bf801362229a0a41bb9f6ac54dcf5921c2eae6e0 100644
--- a/libwccl/values/matchvector.cpp
+++ b/libwccl/values/matchvector.cpp
@@ -90,19 +90,19 @@ void MatchVector::append(const boost::shared_ptr<MatchData> &m)
 }
 
 const boost::shared_ptr<const Match> MatchVector::submatch(size_t idx) const {
-	if (idx + 1< matches_.size() || idx == 0) {
+	if ((idx < matches_.size() + 1) || (idx == 0)) {
 		return matches_[idx - 1];
 	} else {
-		throw Wccl::WcclError("Match vector index out of range");
+		throw Wccl::WcclError("Match vector index out of range.");
 	}
 }
 
 const boost::shared_ptr<Match>& MatchVector::submatch(size_t idx)
 {
-	if (idx + 1 < matches_.size() || idx == 0) {
+	if ((idx < matches_.size() + 1) || (idx == 0)) {
 		return matches_[idx - 1];
 	} else {
-		throw Wccl::WcclError("Match vector index out of range");
+		throw Wccl::WcclError("Match vector index out of range.");
 	}
 }