diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java b/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java
index 179827d63f16c05c78c64153b1e839fdfd652f36..523faab4c6903eabe136a91e15833b6f61f63acd 100644
--- a/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java
+++ b/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java
@@ -133,7 +133,7 @@ public class SearchService implements ISearchService {
 
   /**
    * Adds search prefix for an element class.
-   * 
+   *
    * @param prefix
    *          string prefix used in search queries
    * @param clazz
@@ -147,9 +147,9 @@ public class SearchService implements ISearchService {
   /**
    * Private class that defines internal search result element. Contains reference
    * to original result and match score of the result.
-   * 
+   *
    * @author Piotr Gawron
-   * 
+   *
    */
   private class SearchResult implements Comparable<SearchResult> {
     /**
@@ -207,7 +207,7 @@ public class SearchService implements ISearchService {
   /**
    * Return the list of elements that match the query (sorted by match score)
    * limited to the element of class defined by type.
-   * 
+   *
    * @param model
    *          model where the search is performed
    * @param query
@@ -226,7 +226,10 @@ public class SearchService implements ISearchService {
     if (query.startsWith(REACTION_SEARCH_PREFIX)) {
       return getReactionById(model, query.replaceFirst(REACTION_SEARCH_PREFIX, "").toLowerCase());
     } else if (query.startsWith(SPECIES_SEARCH_PREFIX)) {
-      result.add(model.getElementByElementId(query.replaceFirst(SPECIES_SEARCH_PREFIX, "")));
+      Element element = model.getElementByElementId(query.replaceFirst(SPECIES_SEARCH_PREFIX, ""));
+	  if (element !=null) {
+        result.add(element);
+      }
     } else if (query.startsWith(ELEMENT_SEARCH_PREFIX)) {
       return getElementById(model, query.replaceFirst(ELEMENT_SEARCH_PREFIX, "").toLowerCase());
     } else {
@@ -287,7 +290,7 @@ public class SearchService implements ISearchService {
   /**
    * Returns list with the reaction with a given id. If reaction with such id
    * doesn't exist then empty list is returned.
-   * 
+   *
    * @param model
    *          where the search is performed
    * @param reactionId
@@ -312,7 +315,7 @@ public class SearchService implements ISearchService {
   /**
    * Returns list with the element with a given id. If element with such id
    * doesn't exist then empty list is returned.
-   * 
+   *
    * @param topModel
    *          where the search is performed
    * @param elementId
@@ -341,7 +344,7 @@ public class SearchService implements ISearchService {
 
   /**
    * Transform {@link Reaction} into set of result entries.
-   * 
+   *
    * @param reaction
    *          reaction to be transformed
    * @return set of result entries for all element of the {@link Reaction}
@@ -372,7 +375,7 @@ public class SearchService implements ISearchService {
         }
       }
     }
-    List<BioEntity> result = new ArrayList<>(); 
+    List<BioEntity> result = new ArrayList<>();
     double dist = params.getDistance();
     if (results.size() == 0) {
       Reaction r = null;
@@ -431,7 +434,7 @@ public class SearchService implements ISearchService {
   /**
    * Check if reaction is visible for the user. Reaction is visible when at least
    * one node of the reaction is visible.
-   * 
+   *
    * @param reaction
    *          which reaction is tested
    * @param params
@@ -459,7 +462,7 @@ public class SearchService implements ISearchService {
    * Checks if alias is visible for the user. Alias is invisible when the search
    * is performed on the hierarchical layout and the alias is hidden by the
    * complex or compartment.
-   * 
+   *
    * @param alias
    *          alias to be checked for visibility
    * @param params
@@ -511,7 +514,7 @@ public class SearchService implements ISearchService {
 
   /**
    * Returns elements that are annotated with the given miriam data.
-   * 
+   *
    * @param topModel
    *          model where elements are looked for
    * @param md
@@ -547,7 +550,7 @@ public class SearchService implements ISearchService {
 
   /**
    * Tries to transform query into {@link MiriamData}.
-   * 
+   *
    * @param string
    *          query to transform
    * @return {@link MiriamData} that described query or null if query cannot be
@@ -597,9 +600,9 @@ public class SearchService implements ISearchService {
    * This class represents distance between object and some point. It's designed
    * to help sort objects by their distance to some point. It It contains two
    * fields: object reference and distance.
-   * 
+   *
    * @author Piotr Gawron
-   * 
+   *
    */
   private class DistanceToObject implements Comparable<DistanceToObject> {
     /**
@@ -619,7 +622,7 @@ public class SearchService implements ISearchService {
 
     /**
      * Constructor for reaction objects.
-     * 
+     *
      * @param reaction
      *          reaction reference to store
      * @param point
@@ -633,7 +636,7 @@ public class SearchService implements ISearchService {
 
     /**
      * Constructor for alias objects.
-     * 
+     *
      * @param alias
      *          alias reference to store
      * @param point
@@ -712,7 +715,7 @@ public class SearchService implements ISearchService {
   /**
    * Creates autocomplete map for a model. The key in this map is incomplete typed
    * word, and value list contains suggestions that should appear for this word.
-   * 
+   *
    * @param model
    *          model for which the autocomplete map is created
    * @return autocomplete map for a model. The key in this map is incomplete typed
@@ -779,7 +782,7 @@ public class SearchService implements ISearchService {
 
   /**
    * Returns the list of all human readable search possibilities for alias.
-   * 
+   *
    * @param element
    *          object for which we look for a list of searchable strings
    * @return the list of all human readable search possibilities for alias
diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java
index 1b4495f8f74cde633c22e3a14939acb3a74db9be..336e30a486395369023a6e082f8216f6ba92a3c0 100644
--- a/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java
+++ b/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java
@@ -153,6 +153,20 @@ public class SearchServiceTest extends ServiceTestFunctions {
     }
   }
 
+    @Test
+    public void testSearchByUnknwonElementId() throws Exception {
+        try {
+            Model model = createFullModel();
+            Element element =model.getElements().iterator().next();
+            element.setId(907);
+            List<BioEntity> global = searchService.searchByQuery(model, "species:90111117", 50, null, "127.0.0.1");
+            assertEquals(0, global.size());
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+    }
+
   @Test
   public void testSearchByName4() throws Exception {
     try {