refactoring accept4.