make trimmer a first class part of the algorithm