tried to fix sorting bug