Make sorting less buggy