fixed the empty length bug