implement _Fork and refactor fork using it