cleaned up fork code