I think this fixes the problem around when to check the file extension