change the way to find the length