copied over and fixed selection sort