Adding file type detection routine