Can you change this to `File.basename(path) if path` ?