fixed bug in length