Adding file type detection into statSequence function