I have a working solution for a class method which filters records based on several conditions. But it seems to me that it is too complicated...