update before sort
sorted main