Improve the way to detect file to download