implemented filtering and sorting