Fixed a bug with making sure the sequence being expanded is in the correct range