Add callback to the spawn function