diff --git a/installsystems/repository.py b/installsystems/repository.py
index 32335f02a1c0b2de4f468bca48cb3559b9d23369..e10d3898e33563bee62841e246be173101c9090a 100644
--- a/installsystems/repository.py
+++ b/installsystems/repository.py
@@ -135,16 +135,16 @@ class Repository(object):
         except Exception as e:
             raise Exception("Update last file failed: %s" % e)
 
-    def last(self):
+    def last(self, name):
         '''
-        Return the last value
+        Return last version of name in repo or -1 if not found
         '''
-        try:
-            last_path = os.path.join(config.path, config.lastname)
-            return int(open(last_path, "r").read().rstrip())
-        except Exception as e:
-            raise Exception("Read last file failed: %s" % e)
-        return 0
+        r = self.db.ask("SELECT version FROM image WHERE name = ? ORDER BY version DESC LIMIT 1", (name,)).fetchone()
+        # no row => no way
+        if r is None:
+            return -1
+        # return last
+        return r[0]
 
     def add(self, image, delete=False):
         '''
@@ -433,17 +433,6 @@ class Repository(object):
                         (a[0],)).fetchall()
         return [ a[0] ] + [ x[0] for x in b ]
 
-    def last(self, name):
-        '''
-        Return last version of name in repo or -1 if not found
-        '''
-        r = self.db.ask("SELECT version FROM image WHERE name = ? ORDER BY version DESC LIMIT 1", (name,)).fetchone()
-        # no row => no way
-        if r is None:
-            return -1
-        # return last
-        return r[0]
-
 
 class RepositoryManager(object):
     '''