avoiding erroneous array lengths