Fixing the subdirectory detection