Fixed bug in intial automated sorting