Removed unnecessary isDirectory check