Code modified to adapt to changed external API