fix some bugs in select