improved sort