Implemented filtering and trimming.