Added some checks in filter