fixed reforming the length array