diff --git a/thefuck/utils.py b/thefuck/utils.py
index 8dd777b7..0c3266b0 100644
--- a/thefuck/utils.py
+++ b/thefuck/utils.py
@@ -17,6 +17,23 @@ else:
     from shlex import quote
 
 
+def memoize(fn):
+    """Caches previous calls to the function."""
+    memo = {}
+
+    @wraps(fn)
+    def wrapper(*args, **kwargs):
+        key = pickle.dumps((args, kwargs))
+        if key not in memo or memoize.disabled:
+            memo[key] = fn(*args, **kwargs)
+
+        return memo[key]
+
+    return wrapper
+memoize.disabled = False
+
+
+@memoize
 def which(program):
     """Returns `program` path or `None`."""
 
@@ -55,22 +72,6 @@ def wrap_settings(params):
     return decorator
 
 
-def memoize(fn):
-    """Caches previous calls to the function."""
-    memo = {}
-
-    @wraps(fn)
-    def wrapper(*args, **kwargs):
-        key = pickle.dumps((args, kwargs))
-        if key not in memo or memoize.disabled:
-            memo[key] = fn(*args, **kwargs)
-
-        return memo[key]
-
-    return wrapper
-memoize.disabled = False
-
-
 def get_closest(word, possibilities, n=3, cutoff=0.6, fallback_to_first=True):
     """Returns closest match or just first from possibilities."""
     possibilities = list(possibilities)
@@ -94,7 +95,7 @@ def get_all_executables():
     tf_alias = thefuck_alias()
     return [exe.name
             for path in os.environ.get('PATH', '').split(':')
-            for exe in _safe(lambda: list(Path(path).iterdir()), [])
+            for exe in _safe(Path(path).iterdir, [])
             if not _safe(exe.is_dir, True)] + [
                 alias for alias in get_aliases() if alias != tf_alias]