Modified filter management, now accepts functions too