fixed the length bug