Added a check that the lengths are equal