Fix bug in length