optimize bubble sort