prevents calling lists length many times