added optimized bubble sort