added forking logic