better file type detection