correction bug with sorted