Improve file detection