Updating to use spawn function