modified the the code for the latest version of API, 100% tested and passed in production server