changed to use built-in sorting