Fix selection related bug