diff --git a/invenio_utilities_tuw/cli/drafts.py b/invenio_utilities_tuw/cli/drafts.py
index 8af203af262d6288acf7ca106e7dd8e119f36657..1ae567fc8bebe39ae8bd389bee3a3c5cf8ee8060 100644
--- a/invenio_utilities_tuw/cli/drafts.py
+++ b/invenio_utilities_tuw/cli/drafts.py
@@ -40,6 +40,11 @@ from .utils import (
 )
 
 
+def file_exists(path, filename):
+    """Check if the file exists in the given path."""
+    return isfile(join(path, filename))
+
+
 def auto_increase_bucket_limits(bucket, filepaths, to_unlimited=False):
     """Dynamically increase the bucket quoat if necessary."""
     # see what the file sizes look like
@@ -156,16 +161,20 @@ def create_draft(metadata_path, publish, user, owners, vanity_pid):
         file_paths = []
         if isdir(deposit_files_path):
 
-            def exists(filename):
-                return isfile(join(deposit_files_path, filename))
-
             content = os.listdir(deposit_files_path)
-            file_names = [basename(fn) for fn in content if exists(fn)]
+            file_names = [
+                basename(fn) for fn in content if file_exists(deposit_files_path, fn)
+            ]
+
             for fn in file_names:
                 file_paths.append(join(deposit_files_path, fn))
 
             if len(content) != len(file_names):
-                ignored = [basename(fn) for fn in content if not exists(fn)]
+                ignored = [
+                    basename(fn)
+                    for fn in content
+                    if not file_exists(deposit_files_path, fn)
+                ]
                 msg = f"ignored in '{deposit_files_path}': {ignored}"
                 click.secho(msg, fg="yellow", err=True)
 
@@ -173,6 +182,7 @@ def create_draft(metadata_path, publish, user, owners, vanity_pid):
         file_service.init_files(
             id_=recid, identity=identity, data=[{"key": fn} for fn in file_names]
         )
+
         for fn in file_names:
             file_path = join(deposit_files_path, fn)
             with open(file_path, "rb") as deposit_file:
@@ -313,14 +323,13 @@ def add_files(filepaths, pid, pid_type, user):
     for file_path in filepaths:
         if isdir(file_path):
             # add all files (no recursion into sub-dirs) from the directory
-            def exists(filename):
-                return isfile(join(file_path, filename))
-
             content = os.listdir(file_path)
-            file_names = [basename(fn) for fn in content if exists(fn)]
+            file_names = [basename(fn) for fn in content if file_exists(file_path, fn)]
 
             if len(content) != len(file_names):
-                ignored = [basename(fn) for fn in content if not exists(fn)]
+                ignored = [
+                    basename(fn) for fn in content if not file_exists(file_path, fn)
+                ]
                 msg = f"ignored in '{file_path}': {ignored}"
                 click.secho(msg, fg="yellow", err=True)