sorting bug fixed