Extract the index length validation to a auxiliar method