added preliminary sorting