corrected logic of file-type detection based on file-extension