made sorting more elegant