added adjusted length function