Updated the code to support the latest version