changed sorting method