Fixed mistake with array trimming.