approach 4: search criteria code in an anonymous class