- finally fixed the case-insensitive sorting issue
- simplified the code