improved sorting