adds trimming function