ensure items are sorted correctly
refactoring