Creating the logic for the filter feature, Works well, but still buggy.