length trim script, may be tested