sorting redone (template fixes)