added filtering and sorting