Updated the code to be compatible with the latest SDK