changed sorting, logging