Added the wait and child processes parts. not tested completly