fixed a bug in trim, missed one int when trimming by two segments