Maybe extract a static class to avoid repeated creation of anonymous classes?