changed the order of filtering