logical workflow

changed the logical workflow of functionality of filtering