working without sort