fixed some bugs of selection, now not clearing the selection when changing the mode