reworked sorting and filtration