Length function bugfix