Updated code to v2 SDK