Fixed the sort and filter bugs