updated length calculations
simplify