Added a function smoothLength