Updated to work with latest API updates