class EC2RaiderImpl implements EC2Raider {

    @Override
    public List<EC2InstanceTO> getFilteredActiveInstances(List<String> filteredWords) {
        DescribeInstancesRequest request = new DescribeInstancesRequest();
        ArrayList<String> vals = new ArrayList<>();
        vals.add("running");

        Filter filter = new Filter("instance-state-name", vals);

        List<Reservation> res = ec2Delegator.getEc2().describeInstances(request.withFilters(filter)).getReservations();
        List<String> ids = new ArrayList<>();
        for (Reservation reservation : res) {
            List<Instance> instances = reservation.getInstances();
            for (Instance in : instances) {
                List<Tag> tags = in.getTags();
                Optional<Tag> name = tags.stream().filter(y -> y.getKey().equalsIgnoreCase("name")).findFirst();
                boolean flag = true;
                for (String word : filteredWords) {
                    if (name.isPresent() && name.get().getValue().toLowerCase().contains(word.toLowerCase())) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    ids.add(in.getInstanceId());
                }
            }
        }

        return getEC2InstancesByIds(ids.stream().distinct().collect(Collectors.toList()));
    }

    public  EC2RaiderImpl();

}