safe fork implemented