added filtering and sorting steps