Added trimming functionality