corrected for erros for length