Bug fix in detecting files