Created function for child process