add sorting and global summary, fix naming bug