finish the accept function.
fixing bugs.