script to find trim position