Worked on spawn function