Updated to give the option of sorting