fixed filtering/sorting bug