bug fix in internal trim method