Added check for equal length of the sequences in the input