Added smooth length algorithm