bubble changed loop//fixed nilcase