bug fix to length conversion