fix buffer bug
passed test for select