Fix the bugs in doing Select