Fixing sorting issue