diff --git a/src/utils/utils.js b/src/utils/utils.js
index <HASH>..<HASH> 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -2,12 +2,12 @@
 export function search(node, selector) {
   const result = [];
 
-  let tagsArray;
-
-  if (typeof selector === 'string') {
-    tagsArray = selector.replace(/\./g, ' ').trim().split(' ');
+  if (typeof selector !== 'string') {
+    throw new Error('selector must be a string');
   }
 
+  const tagsArray = selector.replace(/\./g, ' ').trim().split(' ');
+
   const searchIterator = function (node) {
 
     if (typeof selector === 'string') {
throw if selector is not a string