calculate length part 2