added sorting method