Attempt to fix sorting bug