implementing trim