Coverting code to use API filters instead of client side